#include "./../inc/main.h"

// 初始化地图
map_p mapInit()
{
    return load_map();
}

char *getmapInfo(int mapObject)
{
    switch (mapObject)
    {
    case EMPTY:
        return "  ";
    case WALL:
        return "墙";
    case DOOR_BRONZE:
        return COLOR_GREEN "门" COLOR_RESET;
    case DOOR_SILVER:
        return COLOR_WHITE "门" COLOR_RESET;
    case DOOR_GOLD:
        return COLOR_YELLOW "门" COLOR_RESET;
    case PLAYER:
        return COLOR_BLUE "帅" COLOR_RESET;
    case PORTAL_UP:
        return "↑";
    case PORTAL_DOWN:
        return "↓";
    case CHEST:
        return "T";
    case BOSS:
        return COLOR_RED "怪" COLOR_RESET;
    case SLIME:
        return "怪";
    }
}

// 打印地图
void chess(map_p map)
{
    getMapName(map_index);
    for (int i = 0; i < map->map_height; i++)
    {
        for (int j = 0; j < map->map_width; j++)
        {
            printf("%s", getmapInfo(map->map[i][j]));
        }
        printf("\n");
    }
    printf("指令: (W)上 (S)下 (A)左 (D)右 (Z)保存 (ESC)退出游戏\n");
}

char *getMapName(int map_index)
{
    if (map_index == 0)
    {
        printf("\t\t初始大厅\n");
    }
    else
    {
        printf("\t\t第%d层\n", map_index);
    }
}